﻿@using DCMS.Web.Extensions;
@using DCMS.Web.Framework.UI;
@using DCMS.Web.Framework;
@using DCMS.Core.Domain.Common;
@using DCMS.ViewModel.Models.Sales;

@model ReturnBillListModel
@{
 var refURL = Context.Request.GetAbsoluteUri();
}


<section id="content_wrapper">

    <!-- Start: Topbar-Dropdown -->
    <div id="topbar-dropmenu">
        @await Html.PartialAsync("_ToolBox")
    </div>
    <!-- End: Topbar-Dropdown -->
    <!-- Start: Topbar -->
    <header id="topbar">
        <div class="topbar-left">
            <ol class="breadcrumb">
                <li class="crumb-active">
                    <a href="#">销售</a>
                </li>
                <li class="crumb-icon">
                    <a href="@Url.RouteUrl("HomePage")">
                        <span class="glyphicon glyphicon-home"></span>
                    </a>
                </li>
                <li class="crumb-link">
                    <a href="#">销售单据</a>
                </li>
                <li class="crumb-trail">退货单</li>
            </ol>
        </div>
        <div class="topbar-right">
            <div class="ml15 ib va-m" id="toggle_sidemenu_r">
                <a href="#" class="pl5">
                    <i class="fa fa-sign-in fs22 text-primary"></i>
                    <span class="badge badge-hero badge-danger">3</span>
                </a>
            </div>
        </div>
    </header>
    <!-- End: Topbar -->
    <!-- Begin: Content -->
    <section id="content" class="formSection">

        <div class="special-alerts">
            <div class="alert alert-danger light alert-dismissable" id="alert-demo-2" style="display: none;">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <i class="fa fa-info pr10"></i>
                <strong>您没有被授权此操作!</strong>
            </div>
        </div>

        <div class="row">
            <div class="col-md-12">
                <form asp-action="List" asp-controller="ReturnBill" method="get" id="formSearch" novalidate="novalidate">
                    <div class="panel panel-default" id="panel0">
                        <div class="panel-heading">
                            <span class="glyphicon glyphicon-search"></span> 高级搜索
                            <a class="btn btn-default btn-sm pull-right m5 mrn p5 pbn" id="AdvancedSearch"><i class="fa fa-angle-double-right"></i></a>
                        </div>
                        <div class="panel-body p10">
                            @*打印区域*@
                            <div id="printData"></div>
                            <div class="row">
                                <div class="col-sm-2">
                                    <input asp-for="TerminalId" type="hidden" />
                                    <div class="input-group">
                                        <input asp-for="TerminalName" class="form-control" placeholder="客户..." />
                                        <span class="input-group-btn">
                                            <button id="btn_search_customer" type="button" class="btn btn-default">
                                                <span class="glyphicon glyphicon-search"></span>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                                <div class="col-sm-2">
                                    <dcms-select asp-for="BusinessUserId" asp-items="@Model.BusinessUsers" asp-default="选择业务员" />
                                </div>
                                <div class="col-sm-2">
                                    <input asp-for="BillNumber" class="form-control" placeholder="单据号..." />
                                </div>
                                <div class=" col-sm-2">
                                    <dcms-select asp-for="WareHouseId" asp-items="@Model.WareHouses" asp-default="选择仓库" />
                                </div>
                                <div class=" col-sm-2">
                                    <dcms-select asp-for="PaymentMethodType" asp-items="@Html.GetEnumSelectList<ReturnBillPaymentMethodType>().ToSelectListDescription<ReturnBillPaymentMethodType>()" asp-default="请选择" asp-disabled="@(Model.AuditedStatus)" />
                                </div>
                                <div class="col-sm-2">
                                    <input asp-for="Remark" class="form-control" placeholder="备注..." />
                                </div>

                            </div>

                            <div class="row mt10 mb10">
                                <div class=" col-sm-2">
                                    <dcms-editor asp-for="StartTime" placeholder="开始..." />
                                </div>
                                <div class=" col-sm-2">
                                    <dcms-editor asp-for="EndTime" placeholder="结束..." />
                                </div>
                                <div class="col-sm-2">
                                    <dcms-select asp-for="DistrictId" asp-items="@Model.Districts" asp-default="选择区域" />
                                </div>
                                <div class="col-sm-2">
                                    <dcms-select asp-for="DeliveryUserId" asp-items="@Model.DeliveryUsers" asp-default="选择配送员" />
                                </div>

                                <div class=" col-sm-1">
                                    <dcms-select-bool asp-for="AuditedStatus" asp-items="@(new string[] {  "已审核", "未审核"})" asp-default="审核状态" />
                                </div>
                                <div class=" col-sm-1">
                                    <dcms-select-bool asp-for="SortByAuditedTime" asp-items="@(new string[] {  "是", "否"})" asp-default="按审核时间" />
                                </div>
                                <div class=" col-sm-1">
                                    <dcms-select-bool asp-for="ShowReverse" asp-items="@(new string[] {  "是", "否"})" asp-default="显示红冲的数据" />
                                </div>
                                <div class=" col-sm-1">
                                    <dcms-select asp-for="BillSourceType" asp-items="@Html.GetEnumSelectList<ReturnBillSourceType>().ToSelectListDescription<SaleReservationBillPayType>()" asp-default="请选择" asp-disabled="@(Model.AuditedStatus)" />
                                </div>
                            </div>

                            <div class="row">

                                <div class="col-sm-2">
                                    <div class="input-group">
                                        <input asp-for="ProductId" type="hidden" />
                                        <input asp-for="ProductName" class="form-control" placeholder="商品..." />
                                        <span class="input-group-btn">
                                            <button id="btn_search_product" type="button" class="btn btn-default">
                                                <span class="glyphicon glyphicon-search"></span>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                                <div class="col-sm-2">
                                    <a href="@Url.Action("List")" class="btn btn-warning btn-block">
                                        <span class="fa fa-trash-o mr5" aria-hidden="true"></span>清除
                                    </a>
                                </div>
                                <div class="col-sm-8">
                                    <button id="btn_query" type="submit" class="btn btn-primary btn-block">
                                        <span class="glyphicon glyphicon-search mr5" aria-hidden="true"></span>查询
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>

                </form>

                <div class="panel">
                    <div class="panel-heading">
                        <div class="panel-title">
                            <span class="glyphicon glyphicon-tasks"></span> 退货单列表
                        </div>
                    </div>
                    <div class="panel-body p10">

                        <!--Begin _Toolbar-->
                        @await Html.PartialAsync("_Toolbar", Model)
                        <!--End _Toolbar-->

                        <div class="bootstrap-table">

                            <div class="fixed-table-container">
                                <div class="fixed-table-body">
                                    <table class="table table-striped table-bordered table-hover">
                                        <thead>
                                            <tr class="datagrid-header-row">
                                                <th rowspan="2" class="bs-checkbox "><div class="th-inner"><input name="btSelectAll" type="checkbox"></div></th>
                                                <th rowspan="2" class="text-center w150"><div class="th-inner">编号</div></th>
                                                <th rowspan="2" class="text-center w50">详细</th>
                                                <th rowspan="2" class="text-right"><div class="th-inner">应收金额</div></th>
                                                <th rowspan="2" class="text-right"><div class="th-inner">优惠金额</div></th>
                                                <th colspan="@(Model.DynamicColumns.Count)" class="text-center ptn pbn"><div class="th-inner ptn pbn">收款账户</div></th>
                                                <th rowspan="2" class="text-right"><div class="th-inner">欠款金额</div></th>
                                                <th rowspan="2" class="text-center w50">打印</th>
                                                <th rowspan="2" class="text-center w50"><div class="th-inner">状态</div></th>
                                                <th rowspan="2" class="text-center w50"><div class="th-inner">来源</div></th>
                                                <th rowspan="2" class="text-center w50"><div class="th-inner">收款</div></th>
                                                <th rowspan="2" class="text-center w50"><div class="th-inner">对账</div></th>
                                            </tr>
                                            <tr class="datagrid-header-row">
                                                @foreach (var account in Model.DynamicColumns)
                                                {
                                                <th class="text-right ptn pbn"><div class="th-inner ptn pbn">@account</div></th>
                                                }

                                            </tr>
                                        </thead>
                                        <tbody>
                                            @{
                                                if (Model.Lists == null || Model.Lists.Count == 0)
                                                {
                                                <tr class="no-records-found"><td colspan="@(Model.DynamicColumns.Count + 12)">没有找到匹配的记录</td></tr>
                                                }
                                                else
                                                {
                                                    foreach (var r in Model.Lists)
                                                    {
                                                <tr>
                                                    <td class="bs-checkbox ">
                                                        <input name="btSelectItem" class="btSelectItem" type="checkbox" value="@r.Id">
                                                    </td>
                                                    <td class="text-center">
                                                        <a href="@Url.Action("Edit","ReturnBill",new { id= r.Id,returnURL= refURL})">@r.BillNumber</a>
                                                        @if (r.ReturnReservationBillId != 0)
                                                {
                                                        <br />
                                                        <a href="@Url.Action("Edit","ReturnReservationBill",new { id= r.ReturnReservationBillId})" style="color:#ddd">@r.ReturnReservationBillNumber</a>
                                                }
                                                    </td>
                                                    <td class="text-center">
                                                        <a href="javascript:;" class="showSubChildRow" data-id="@r.Id" data-open="false"><i class="fa fa-plus"></i></a>
                                                    <td class="text-right">￥ @r.ReceivableAmount.ToString("0.00")</td>
                                                    <td class="text-right">￥ @r.PreferentialAmount.ToString("0.00")</td>

                                                    @if (r.ReturnBillAccountings == null || r.ReturnBillAccountings.Count == 0)
                                            {
                                                    <td class="text-right"></td>
                                            }
                                            else
                                            {
                                                    @foreach (var account in r.ReturnBillAccountings)
                                                {
                                                    <td class="text-right">￥ @account.CollectionAmount.ToString("0.00")</td>
                                                }
                                            }

                                                    <td class="text-right">
                                                        ￥ @Html.Raw((r.OweCash != 0) ? "<b>" + r.OweCash.ToString("0.00") + "</b>" : r.OweCash.ToString("0.00"))
                                                    </td>

                                                    <td class="text-center">
                                                        @if (r.PrintNum > 0)
                                                {
                                                        <span class="label label-info">已打印</span>
                                                }
                                                else
                                                {
                                                        <span class="label label-default">未打印</span>
                                                }
                                                    </td>
                                                    <td class="text-center">
                                                        @Html.AuditedStatus(r.ReversedStatus, r.AuditedStatus)
                                                    </td>
                                                    <td class="text-center">
                                                        @Html.Operation(r.Operation)
                                                    </td>
                                                    <td class="text-center">

                                                        @Html.ReceiptStatus(r.ReceiptStatus)
                                                    </td>
                                                    <td class="text-center">
                                                        @if (r.HandInStatus ?? false)
                                                {
                                                        <span class="label label-info">已上缴</span>
                                                }
                                                else
                                                {
                                                        <span class="label label-default">未上缴</span>
                                                }
                                                    </td>
                                                </tr>
                                                <tr class="showSubChildRow_@r.Id" style="display:none">
                                                    <td colspan="2"></td>
                                                    <td class="text-center"><span>详细</span></td>
                                                    <td colspan="2" class="text-left">
                                                        业务员：@(r.BusinessUserName)
                                                        <br />
                                                        客户：@(r.TerminalName)
                                                        <br />
                                                        客户编码：@(r.TerminalPointCode)
                                                        <br />
                                                        仓库：@(r.WareHouseName)
                                                        <br />
                                                        交易时间：@(r.TransactionDate.HasValue ? r.TransactionDate.Value.ToString("yyyy/MM/dd HH:mm:ss") : "")
                                                        <br />
                                                        审核时间：@(r.AuditedDate.HasValue ? r.AuditedDate.Value.ToString("yyyy/MM/dd HH:mm:ss") : "")
                                                        <br />
                                                        打印数：@(r.PrintNum)
                                                        <br />
                                                        备注：@(r.Remark)
                                                    </td>
                                                    <td colspan="10">
                                                        <table class="table table-striped table-bordered table-hover" id="ReturnItems_@r.Id"></table>
                                                    </td>
                                                </tr>
                                                    }
                                                }

                                            }

                                        </tbody>
                                    </table>
                                </div>
                            </div>

                            @{
                                var pager = Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber");
                            }

                            @if (!pager.IsEmpty())
                            {
                            <div class="fixed-table-pagination" style="display: block;">
                                @Html.Raw(pager.ToString())
                            </div>
                            }

                            <div class="clearfix"></div>
                        </div>

                    </div>
                </div>
            </div>
        </div>

    </section>

</section>



@{

    await Html.RenderPartialAsync("_ModalForm", new ViewDataDictionary(ViewData) { { "formId", "TerminalSelectForm" }, { "modalWindow", "TerminalSelectModalWindow" }, { "windowWidth", "1000px" }, { "showSave", "true" } });
    //商品选择
    await Html.RenderPartialAsync("_ModalForm", new ViewDataDictionary(ViewData) { { "formId", "ProductModalForm" }, { "modalWindow", "ModalProductWindows" }, { "windowWidth", "1000px" }, { "showSave", "true" } });
}



@section CurPageScripts
{
    <script type="text/javascript">

        jQuery(document).ready(function () {

            "use strict";

            // Init Theme Core
            Core.init();

            // Init Demo JS
            Demo.init();

            //权限提示
            if ($(this).getUrlQueryString("Authorize") == "noAuthorize") {
                $('#alert-demo-2').fadeToggle();
                setTimeout(function () {
                    $('#alert-demo-2').fadeToggle();
                }, 3000);
            }

            //商品列表选择赋值
            window.operateEventsPop = {
                'click .rowSelect': function (e, value, row, index) {
                    var index = $(this).attr("data-id");
                    var keys = Object.keys(row.Units);
                    $("#ProductName").val(row.Name);
                    $("#ProductId").val(row.Id);
                    $('#ModalProductWindows').modal('hide');
                }
            };
            $("#btn_search_product").click(function () {
                $(this).productSelectShowModal($("#ModalProductWindows"), "/Product/AsyncSearchSelectPopup", null, "选择商品", $("#ProductModalForm"),
                    function () { });
            });


            //全选
            $("input[name='btSelectAll']").click(function () {
                var selectStatus = $(this).is(':checked')
                if (selectStatus) {
                    $("input[name='btSelectItem']").each(function (i, n) {
                        n.checked = true;
                    });
                } else {
                    $("input[name='btSelectItem']").each(function (i, n) {
                        n.checked = false;
                    });
                }
            });

            //高级搜索
            $("#panel0 #AdvancedSearch").click(function () {
                var ico = $(this).find(".fa");
                if (ico.hasClass('fa-angle-double-right'))
                    ico.removeClass("fa-angle-double-right").addClass("fa-angle-double-down");
                else
                    ico.removeClass("fa-angle-double-down").addClass("fa-angle-double-right");
                $("#panel0").find(".panel-body").toggleClass("hidden fadeIn");
            });

            //客户搜索
            $(document).on('click', "#btn_search_customer", function () {
                var actionUrl = "/Terminal/AsyncSearchSelectPopup";
                $(this).showModalV2($("#TerminalSelectModalWindow"), actionUrl, { ids: "" }, "选择终端", $("#TerminalSelectForm"), function (rows) { });
            });

            window.operateEventsPopTerminal = {
                'click .rowSelect': function (e, value, row, index) {
                    try {
                        $("#TerminalId").val(row.Id);
                        $("#TerminalName").val(row.Name);
                        $('#TerminalSelectModalWindow').modal('hide');
                    }
                    catch (err) {
                        console.log(err);
                        $(this).showToastr(err);
                        return;
                    }
                }
            };


            //导出选择
            $("#export_select").click(function () {
                Export(1);
            });
            //导出全部
            $("#export_all").click(function () {
                Export(2);
            });
            var Export = function (t) {
                var queryParams = {};
                queryParams.type = t;
                queryParams.selectData = "";
                if (t == 1) {
                    var selectData = "";
                    //获取用户选择的单据
                    var arrselections = $("input[name='btSelectItem']:checked").each(function (i, j) {//把所有被选中的复选框的值存入数组
                        selectData += (selectData != "" ? "," : "") + $(this).val();
                    });

                    if (selectData == "") {
                        $(this).showToastr("没有选择数据");
                        return false;
                    }
                    queryParams.selectData = selectData;

                }
                BindQueryParams(queryParams);
                window.location.href = "/ReturnBill/Export?type=" + queryParams.type + "&selectData=" + queryParams.selectData + "&terminalId=" + queryParams.TerminalId + "&businessUserId=" + queryParams.BusinessUserId + "&billNumber=" + queryParams.BillNumber + "&wareHouseId=" + queryParams.WareHouseId + "&paymentMethodType=" + queryParams.PaymentMethodType + "&remark=" + queryParams.Remark + "&startTime=" + queryParams.StartTime + "&endTime=" + queryParams.EndTime + "&districtId=" + queryParams.DistrictId + "&deliveryUserId=" + queryParams.DeliveryUserId + "&auditedStatus=" + queryParams.AuditedStatus + "&sortByAuditedTime=" + queryParams.SortByAuditedTime + "&showReverse=" + queryParams.ShowReverse + "&billSourceType=" + queryParams.BillSourceType + "&terminalName=" + queryParams.TerminalName;

            }

            //打印选择
            $("#print_select").click(function () {
                Print(1);
            });
            //打印全部
            $("#print_all").click(function () {
                Print(2);
            });
            var Print = function (t) {
                var loadingButton = Ladda.create($("#btn_print")[0]);
                var queryParams = {};
                queryParams.type = t;
                queryParams.selectData = "";
                if (t == 1) {
                    var selectData = "";
                    //获取用户选择的单据
                    var arrselections = $("input[name='btSelectItem']:checked").each(function (i, j) {//把所有被选中的复选框的值存入数组
                        selectData += (selectData != "" ? "," : "") + $(this).val();
                    });

                    if (selectData == "") {
                        $(this).showToastr("没有选择数据");
                        return false;
                    }
                    queryParams.selectData = selectData;

                }
                BindQueryParams(queryParams);
                WinMsg.confirm({ message: "打印单据吗？" }).on(function (e) {
                    if (!e) {
                        return;
                    }
                    loadingButton.start();
                    var setting = {}
                    var LODOP = null;
                    var rs = $(this).getSyncData("/ReturnBill/PrintSetting", null, "get");
                    if (rs.Success) {
                        setting = rs.Data;
                        loadCLodop(document, setting.PrintPort, () => {
                            //判断页面是否已加载LODOP
                            if (LODOP == null || LODOP == undefined) {
                                LODOP = getLodopFirst(document);
                                LODOP = getLodopSecond(document);
                            }
                            if (LODOP == null || LODOP == undefined) {
                                loadingButton.stop();
                                return;
                            } else {
                                $("#printData").html("");
                            }
                            $(this).remoteRequest('GET', '/ReturnBill/Print', queryParams, function (result) {
                                if (result.Success) {
                                    var htmls = result.Data;
                                    LODOP.PRINT_INIT("销售订单");
                                    if (!isNaN(setting.PaperWidth) && !isNaN(setting.PaperHeight)) {
                                        LODOP.SET_PRINT_PAGESIZE(1, setting.PaperWidth + "mm", setting.PaperHeight + "mm");
                                    }
                                    htmls.forEach(function (html, index) {
                                        if (setting.IsPrintPageNumber) {
                                            LODOP.ADD_PRINT_HTM(1, 600, 300, 100, "总页号：<font color='#0000ff' format='ChineseNum'><span tdata='pageNO'>第##页</span>/<span tdata='pageCount'>共##页</span></font>");
                                        }
                                        if (!isNaN(setting.MarginTop) && !isNaN(setting.MarginLeft) && !isNaN(setting.MarginRight) && !isNaN(setting.MarginBottom)) {
                                            LODOP.ADD_PRINT_HTM(setting.MarginTop + "mm", setting.MarginLeft + "mm", "RightMargin:" + setting.MarginRight + "mm", "BottomMargin:" + setting.MarginBottom + "mm", html);
                                        }
                                        LODOP.NewPageA();
                                    });
                                    LODOP.SET_PRINT_STYLEA(0, "Horient", 2);
                                    LODOP.PREVIEW(true);
                                    loadingButton.stop();
                                }
                                else {
                                    $(this).showToastr(result.Message);
                                    loadingButton.stop();
                                }
                            });
                        });
                    }
                });
            }

            //绑定查询参数
            var BindQueryParams = function (queryParams) {
                queryParams.TerminalId = $("#TerminalId").val();
                queryParams.TerminalName = $("#TerminalName").val();
                queryParams.BusinessUserId = $("#BusinessUserId").val();
                queryParams.BillNumber = $("#BillNumber").val();
                queryParams.WareHouseId = $("#WareHouseId").val();
                queryParams.PaymentMethodType = $("#PaymentMethodType").val();
                queryParams.Remark = $("#Remark").val();
                //queryParams.StartTime = $("#datetimepicker_StartTime").val();
                //queryParams.EndTime = $("#datetimepicker_EndTime").val();
                queryParams.StartTime = $("#StartTime").val();
                queryParams.EndTime = $("#EndTime").val();
                queryParams.DistrictId = $("#DistrictId").val();
                queryParams.DeliveryUserId = $("#DeliveryUserId").val();
                queryParams.AuditedStatus = $("#AuditedStatus").val();
                queryParams.SortByAuditedTime = $("#SortByAuditedTime").val();
                queryParams.ShowReverse = $("#ShowReverse").val();
                queryParams.AlreadyChange = $("#BillSourceType").val();
            }

            //防止重复查询
            var queryNumber = 1;
            $("#btn_query").click(function () {
                if (queryNumber > 1) {
                    return false;
                }
                queryNumber = queryNumber + 1;
            });

            //用户修改客户名称，将客户Id置零
            $("#TerminalName").bind("change", function () {
                $("#TerminalId").val(0);
            });



            //折叠项目  //minus
            $(".showSubChildRow").click(function () {
                var id = $(this).attr("data-id");
                var open = $(this).attr("data-open");
                if (open == "true") {
                    $(".showSubChildRow_" + id).hide();
                    $(this).attr("data-open", false);
                    $(this).html('<i class="fa fa-plus"></i>');
                }
                else {
                    $(".showSubChildRow_" + id).show();
                    $(this).attr("data-open", true);
                    $(this).html('<i class="fa fa-minus"></i>');

                    //载入明细
                    $("#ReturnItems_" + id).bootstrapTable({
                        url: '/ReturnBill/AsyncReturnItems?returnBillId=' + id,
                        striped: true,
                        cache: false,
                        pagination: true,
                        showPagination: false,
                        sidePagination: "server",
                        sortable: false,
                        sortOrder: "asc",
                        search: false,
                        strictSearch: false,
                        showColumns: false,
                        showRefresh: false,
                        clickToSelect: false,
                        uniqueId: "id",
                        showToggle: false,
                        editable: true,
                        cardView: false,
                        detailView: false,
                        showFooter: true,
                        onLoadSuccess: function (data) {
                            //$(".fixed-table-pagination").hide();
                        },
                        onPostBody: function (data) {
                            $("[data-toggle='popover']").popover();
                        },
                        columns: [
                            {
                                title: '<i class="fa fa-gear fs18"></i>', align: 'center',
                                formatter: function (value, row, index) {
                                    return m_pagerow + index + 1;
                                },
                                footerFormatter: function (value) {
                                    return '总计';
                                }
                            },
                            {
                                field: 'ProductCode',
                                title: '商品编号',
                                align: 'center',
                            },
                            {
                                field: 'ProductName',
                                title: '商品名称',
                                align: 'center',
                                width: 300
                            },
                            {
                                field: 'SmallBarCode',
                                title: '条形码',
                                align: 'center',
                                formatter: $(this).formatIsNull
                            },
                            {
                                field: 'UnitName',
                                title: '单位',
                                align: 'center',
                                formatter: $(this).formatIsNull
                            },
                            {
                                field: 'UnitConversion',
                                title: '单位换算',
                                align: 'center',
                                formatter: $(this).formatIsNull
                            },
                            {
                                field: 'Quantity',
                                align: 'center',
                                width: '100',
                                title: '数量',
                                formatter: function (value, row, index) {
                                    if (Object.keys(row).length > 1) {
                                        return (value == 0 || value == "") ? "" : value + "" + row.UnitName;
                                    }
                                    else {
                                        return "";
                                    }
                                }
                            },
                            {
                                field: 'ManufactureDete',
                                title: '生产日期',
                                align: 'center', visible: false
                            },
                            {
                                field: 'Price',
                                title: '价格',
                                width: '100',
                                formatter: function (value, row, index) {
                                    if (Object.keys(row).length > 1) {
                                        value = $(this).formatFixed(value);

                                        if (row.ReferPrices && row.ReferPrices != "" && row.ReferPrices != null) {
                                            if (value != "" && value != row.ReferPrices) {
                                                return "<span alt=" + value + " style='color:#f34a70;'>" + value + "</span>";
                                            }
                                            else {
                                                return value;
                                            }
                                        }
                                        else {
                                            if (value != "" && value != row.Prices[0].ProductPrice.TradePrice) {
                                                return "<span alt=" + value + " style='color:#f34a70;'>" + value + "</span>";
                                            }
                                            else {
                                                return value;
                                            }
                                        }
                                    }
                                    else {
                                        return (value == 0 || value == "" || value == undefined) ? "" : value
                                    }
                                },
                                align: 'center'
                            },
                            {
                                field: 'Amount',
                                title: '金额',
                                width: '100',
                                align: 'center',
                                formatter: function (value, row, index) {
                                    return (value == 0 || value == "" || value == undefined) ? "" : parseFloat(value).toFixed(2);
                                },
                                footerFormatter: function (value) {
                                    var count = $(this).alculateTaxAmountSub(id, 'true', '#ReturnItems_' + id, 'false', value);
                                    var total = parseFloat((typeof (count) == 'undefined' || count == "") ? '0' : count);
                                    return total.toFixed(2);
                                }
                            },
                            {
                                field: 'Remark',
                                title: '备注',
                                align: 'center',
                                formatter: $(this).formatIsNull
                            },
                        ]
                    });
                }
            });


        });

    </script>

}